library lib_ui;

import 'package:flutter/services.dart';

mixin PageLifecycle {
  void registerPageLifecycle({required MethodChannel channel}) {
    channel.setMethodCallHandler((call) async {
      switch (call.method) {
        case 'onPageWillShow':
          onPageWillShow();
          return true;

        case 'onPageDidShow':
          onPageDidShow();
          return true;

        case 'onPageWillHide':
          onPageWillHide();
          return true;

        case 'onPageDidHide':
          onPageDidHide();
          return true;

        case 'onPageDispose':
          onPageDispose();
          return true;

        case 'onKeyboardShow':
          onKeyboardShow(call.arguments);
          return true;

        case 'onKeyboardHide':
          onKeyboardHide(call.arguments);
          return true;

        default:
          return false;
      }
    });
  }

  void onPageWillShow() {}

  void onPageDidShow() {}

  void onPageWillHide() {}

  void onPageDidHide() {}

  void onPageDispose() {}

  void onKeyboardShow(double height) {}

  void onKeyboardHide(double height) {}
}
